﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using ProjectStorageLib.Project;
using ProjectStorageLib.User;

public partial class CtrlProjectList : System.Web.UI.UserControl
{
    public ProjectFilter ProjectFilter { get; set; }
    public ProjectsManager Manager { get; private set; }

    public IEnumerable<ProjectManager> Projects
    {
        get;
        private set;
    }

    protected void Page_Load(object sender, EventArgs e)
    {
        Manager = new ProjectsManager(ProjectFilter);

        UserProcessor uproc = new UserProcessor();
        if (uproc.IsUserAdmin(Security.GetCurrentUserID()) == true)
        {
            m_gvProjects.Columns[m_gvProjects.Columns.Count - 1].Visible = true;
            Projects = Manager.GetAllProjects();
        }
        else
        {
            m_gvProjects.Columns[m_gvProjects.Columns.Count - 1].Visible = false;
            Projects = Manager.GetResult();
        }

    }
}